import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class array {
    public static void main(String[] args) {
        // 动态初始化
        int[] arr = new int[]{1, 2, 3};
        // 简化初始化
        int[] arr1 = {1, 2, 3, 4, 5};
        String[] arr2 = {"张三", "李四", "王五", "赵六"};

        for (String s : arr2) {
            System.out.println(s);
        }
        System.out.println(Arrays.toString(arr2));

        System.out.println("===================");

        int[] arr3 = {1, 3, 2, 6, 4, 10, 5, 30, 20};
        int maxValue = 0;
        for (int i : arr3) {
            if (i > maxValue) {
                maxValue = i;
            }
        }
        System.out.println(maxValue);
        System.out.println("====================");
        /*
         * 练习
         * 随机产生10个[0,100]之间整数，统计既是3又是5，但不是7的倍数的个数
         * */
        int few = 0;
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            int omptyValue = random.nextInt(101);
            System.out.println("omptyValue = " + omptyValue);
            if (omptyValue % 3 == 0 && omptyValue % 5 == 0 && omptyValue % 7 != 0) {
                few++;
            }
        }
        System.out.println(few);

        System.out.println("====================");
        /*
         * 练习
         * 随机录入一个整数，找出整数在数组中存储的索引位置
         * */
        int[] arr4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入需要寻找的值：");
        int n = sc.nextInt();
        for (int i = 0; i < arr4.length; i++) {
            if (n == arr4[i]) {
                System.out.println("这个值在数组的第" + (i + 1) + "项");
            }
        }

        System.out.println("================");

        
    }
}
